//
//  PYQListCell.swift
//  SheYangBigData
//
//  Created by 宋海胜 on 2020/12/29.
//  Copyright © 2020 叁拾叁. All rights reserved.
//

import UIKit
import SnapKit
import SwiftDate

class PYQListCell: SYBaseCell {

    
    let dayLb: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 21.autoBoldFontSize()
        
        return v
    }()
    
    let monthLb: UILabel = {
        let v: UILabel = UILabel()
        v.font = autoFontSize(12)
        v.textColor = UIColor(hex: 0x333333)
        
        return v
    }()
    
    let textContent: UIView = {
        let v: UIView = UIView()
        v.backgroundColor = UIColor(hex: 0xF7F7F7)
        v.layer.cornerRadius = 2
        return v
    }()
    
    let contentLb: UILabel = {
        let v: UILabel = UILabel()
        v.font = 16.autoFontSize()
        v.textColor = UIColor(hex: 0x1E1E1E)
        
        return v
    }()
    
    public func configure(model: NSVoListModel) {
        
        if let d = model.updateDate {
            let date = DateInRegion(d)
            dayLb.text = "\(date?.day ?? 0)"
            monthLb.text = "\(date?.month ?? 0)月"
        } else if let d = model.createDate {
            let date = DateInRegion(d)
            dayLb.text = "\(date?.day ?? 0)"
            monthLb.text = "\(date?.month ?? 0)月"
        } else {
            dayLb.text = ""
            monthLb.text = ""
        }
        
        contentLb.text = model.content
    }
    
    override func initViews() {
        
        addSubview(dayLb)
        addSubview(monthLb)
        addSubview(textContent)
        textContent.addSubview(contentLb)
        dayLb.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(2.5.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(15.5))
            make.width.equalTo(28.0.autoWidth())
            make.height.equalTo(16.0.autoWidth())
        }
        monthLb.snp.makeConstraints { (make) in
            make.bottom.equalTo(dayLb.snp.bottom)
            make.left.equalTo(dayLb.snp.right).offset(autoWidth(3.0))
            make.width.equalTo(25.0.autoWidth())
            make.height.equalTo(11.0.autoWidth())
        }
        textContent.snp.makeConstraints { (make) in
            make.top.equalToSuperview()
            make.left.equalTo(monthLb.snp.right).offset(autoWidth(12.0))
            make.right.equalToSuperview().offset(autoWidth(-15.5))
            make.height.equalTo(33.0.autoWidth())
            make.bottom.equalToSuperview().offset(-30.0.autoWidth())
        }
        contentLb.snp.makeConstraints { (make) in
            make.top.bottom.equalToSuperview()
            make.left.equalToSuperview().offset(4.0.autoWidth())
            make.right.equalToSuperview().offset(4.0.autoWidth())
        }
    }
}
